using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using System.Collections.Generic;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework;
using Castle.ActiveRecord.Framework.Config;
using WOODIFramework.Model;

namespace WOODIFramework.Model.Test
{
    /// <summary>
    ///This is a test class for WOODIFramework.Model.Page and is intended
    ///to contain all WOODIFramework.Model.Page Unit Tests
    ///</summary>
    [TestClass()]
    class BuildPages
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        private void InitActiveRecord()
        {
            XmlConfigurationSource config = new XmlConfigurationSource("NonTestConfig.xml");
            ActiveRecordStarter.Initialize(System.Reflection.Assembly.Load("WOODIFramework.Model"), config);
            
        }

        private void RecreateSchema()
        {
            ActiveRecordStarter.DropSchema();
            ActiveRecordStarter.CreateSchema();
        }

        [TestMethod()]
        public void BuildBasicPageWithLabel()
        {
            InitActiveRecord();
            RecreateSchema();

            Page page = BasicPage.NewBasicPage("BasicPage");
            Label label = Label.CreateLabel("Title", "Basic Page");
            label.Create();
            page.Items.Add(label);

            page.Create();
        }
    }
}
